{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "metric-diagnosis",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/find-all-duplicates-in-an-array\n",
    "\n",
    "\n",
    "Runtime: 140 ms, faster than 20.20% of C++ online submissions for Find All Duplicates in an Array.\n",
    "Memory Usage: 46.6 MB, less than 7.04% of C++ online submissions for Find All Duplicates in an Array.\n",
    "\n",
    "\n",
    "```c++\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "#include <map>\n",
    "#include <string>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    vector<int> findDuplicates(vector<int>& nums) {\n",
    "        map<int,int> m;\n",
    "        vector<int> l;\n",
    "        for (auto n : nums) {\n",
    "            if (m.find(n) != m.end()) {\n",
    "                m[n] += 1;\n",
    "                l.push_back(n);\n",
    "            } else {\n",
    "                m.insert(pair<int, int>{n, 1});\n",
    "            }\n",
    "        }\n",
    "        return l;\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "inappropriate-production",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
